package com.ssm.web;

import com.ssm.Service.choosePinService;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "choosePinServlet",urlPatterns = "/choose2")
public class choosePinServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String type=request.getParameter("type");

//        System.out.println("种类："+type);

        choosePinService choosePinService=new choosePinService();
        List<Object> objectList = choosePinService.choosePin(type);

//        for (Object object : objectList) {
//            Object[] o = (Object[]) object;
//            for (Object ob : o) {
//                System.out.println(ob.toString());
//            }
//        }

        JSONArray data=JSONArray.fromObject(objectList);
        PrintWriter writer=response.getWriter();
        writer.print(data);
        writer.close();
    }
}
